home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / batch / tsbat36.zip / PROMPT.TXT < prev    next >
Text File  |  1992-06-10  |  5KB  |  118 lines

  1. This file contains prompt tips by              (All rights reserved)
  2. Prof. Timo Salmi
  3. Moderating at garbo.uwasa.fi anonymous FTP archives 128.214.87.1
  4. Faculty of Accounting & Industrial Management; University of Vaasa
  5. Internet: ts@uwasa.fi Bitnet: salmi@finfun   ; SF-65101, Finland
  6.  
  7. This file belongs to TSBAT*.ZIP.  Please do not distribute it
  8. separately.
  9.  
  10. 1) If you have programs that can shell to dos it would be nice to
  11. know whether you currently are in a dos shell or not. Else you might
  12. call the same program again from the shell and eventually run out of
  13. memory. There is a rather straight-forward trick for this. Assume
  14. that your program is called prog.exe. You can always call the
  15. program from a batch, say pro.bat. Include the following lines in
  16. your batch:
  17.  
  18.   set _prompt=%prompt%
  19.   set prompt=%_prompt%[in shell or whatever text]
  20.   prog %1 %2 %3 %4 %5 %6 %7 %8 %9
  21.   set prompt=%_prompt%
  22.   set prompt=
  23.  
  24. The method will not work or will produce unexpected results if the
  25. program itself manipulates the prompt when shelling to Dos. Some
  26. (usually advanced) programs do.
  27.  
  28. Another trick to avoid double loading is shown in the following
  29. skeleton
  30.   if "%_loaded%"=="yes" exit
  31.   set _loaded=yes
  32.   prog %1 %2 %3 %4 %5 %6 %7 %8 %9
  33.   set _loaded=
  34.  
  35.  
  36. 2) A frequently asked question about ansi.sys is now does one use it
  37. to redefine keyboard keys. Here is an example which redefines the F1
  38. key invoke the directory "dir" command, the F2 key to invoke the
  39. "dir/w" command, and the F3 to type the Scandinavian letter ä.
  40.    prompt $e[0;59;"dir";13p
  41.    prompt $e[0;60;"dir/w";13p
  42.    prompt $e[0;61;"ä"p
  43.    prompt $p$g
  44.  
  45. The last line is needed to restore the prompt in its usual format
  46. (which I have as $p$g).
  47.  
  48. To cancel the definitions apply
  49.    prompt $e[0;59;;p
  50.    prompt $e[0;60;;p
  51.    prompt $e[0;61;;p
  52.    prompt $p$g
  53.  
  54. This system requires that you have ansi.sys loaded in your
  55. config.sys file
  56.    device=c:\dos\ansi.sys
  57.  
  58. Note that ansi.sys replacements like zansi.sys (which I normally use
  59. myself) do not have the key-redefinition feature. This has one
  60. advantages, that is protecting you against the so-called ansi bombs.
  61.  
  62. The 0;59 pair defines F1 because it is that key's scan code. To get
  63. the scan codes of the different keys you need either a scan code
  64. table or a program that gives the scan code of the key you have
  65. pressed. One such program is garbo.uwasa.fi:/pc/keyboard/keyb21.zip.
  66.  
  67.  
  68. 3) You can devise quite complicated ansi prompts to do flashy
  69. things although much of this is rather computer entertainment than
  70. serious usage. Let look at some examples
  71.  
  72. My ordinary prompt is the simple
  73.    prompt $p$g
  74. which displays the directory followed bu the > sign. Furthermore I
  75. use bright yellow on black, but for that I apply echo 
  76.  
  77. Let's build from that.
  78.    prompt $d $t$_$p$g
  79. Gives the date and the time on the first line ($d $t), then on the
  80. second ($_) gives the current directory ($p) and the > sign ($g).
  81.  
  82. Lets take a little more complicated example next:
  83.    prompt $e[s$e[1;69H$t$h$h$h$e[u$p$g
  84. This is of of the basic prompt tricks, and it puts the time in the
  85. upper right corner of the screen. First the current cursor postion
  86. is stored ($e[s); the cursor is moved to row 1, column 69 ($e[1;69H)
  87. the time is displayed ($t); the hundredths of a second are deleted
  88. ($h$h$h); the original cursor position is restored ($e[u); and
  89. finally the current directory and the > sign are displayed ($p$g).
  90.  
  91. The next obvious step is to display the time in some garish reverse.
  92. For the normal part of the prompt lets use my own default which is
  93. bright yellow on black ($e[40;33;1m).
  94.    prompt $e[s$e[1;69H$e[41;32;1m$t$e[40;33;1m$h$h$h$e[u$p$g
  95. The time is displayed in bright green on red ($e[41;32;1m).
  96.  
  97. The interpretation of the following prompt is left as an exercise:
  98.    prompt $e[s$e[H$e[43;30m$e[KDirectory $p $d $t $h$h$h$h $v
  99.           $e[40;33;1m$e[2;1H$e[K$e[u$p$g
  100. Note that you must have everything on one line only. The wrap here
  101. is just for readability.
  102.  
  103. One example of an "entertainment" prompt just to give the general
  104. idea:
  105.    prompt $e[s$_$e[40;37m██$e[34m██$e[37m████$_$e[34m████████
  106.           $e[40;37m$_██$e[34m██$e[37m████$e[40;33m $p$g
  107. Note that you must have everything on one line only. The wrap here
  108. is just for readability.
  109.  
  110. The difference in using the echo and the prompt for setting the
  111. screen colors is that the echo is invoked only when you apply it,
  112. but the prompt is called each time the dos prompt appears.
  113.  
  114.  
  115. 4) If you are having problems you can "debug" your prompt by giving
  116. the set command in MsDos which displays your environment variables
  117. including the prompt variable.
  118.